Skip to content

ci: cache vivisect workspaces between CI runs to speed up tests#2881

Merged
mr-tz merged 3 commits intomandiant:masterfrom
kami922:fix-556-vivisect-workspace-cache
Feb 25, 2026
Merged

ci: cache vivisect workspaces between CI runs to speed up tests#2881
mr-tz merged 3 commits intomandiant:masterfrom
kami922:fix-556-vivisect-workspace-cache

Conversation

@kami922
Copy link
Contributor

@kami922 kami922 commented Feb 24, 2026

Summary

Fixes #556

CI always starts cold because *.viv workspace files are in .gitignore and never committed. This means vivisect re-analyzes every binary on every CI run.

This PR adds a actions/cache@v4 step to the tests job that persists tests/data/**/*.viv between runs, keyed on OS + architecture + Python version + hash(requirements.txt).

How it works

  • Cache hit (subsequent runs): .viv files are restored before pytest starts → vivisect skips re-analysis
  • Cache miss (first run, or after vivisect version bump): tests run cold, generate .viv files, cache is saved for next run
  • Cache key includes hashFiles('**/requirements.txt') so it auto-invalidates when the vivisect version changes — no risk of stale workspaces

Benchmark (local, mimikatz — 112 viv feature tests)

Condition Time
Cold (no .viv, same as CI today) 118.95s
Warm (.viv cached) 8.65s
Speedup ~14x

CI benchmark from this PR (run 1 cold vs run 2 warm) will be posted once workflows are approved.

Checklist

  • No CHANGELOG update needed
  • No new tests needed
  • No documentation update needed
  • This submission includes AI-generated code and I have provided details in the description.

CI always starts cold because *.viv files are in .gitignore and never
committed. Benchmark on mimikatz (112 viv feature tests): 8.65s WITH
cache vs 118.95s WITHOUT — roughly 14x speedup.

Add a GitHub Actions cache step that persists tests/data/**/*.viv
between runs. Cache key includes OS, architecture, Python version, and
a hash of requirements.txt so it auto-invalidates when the vivisect
version is bumped. On a cache miss tests fall back to cold execution
normally; the cache is a pure optimization with no hard dependency.

fixes mandiant#556
@gemini-code-assist
Copy link
Contributor

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add bug fixes, new features, breaking changes and anything else you think is worthwhile mentioning to the master (unreleased) section of CHANGELOG.md. If no CHANGELOG update is needed add the following to the PR description: [x] No CHANGELOG update needed

@kami922 kami922 changed the title ci: cache vivisect workspaces between test runs (fork test) ci: cache vivisect workspaces between CI runs to speed up tests Feb 24, 2026
@github-actions github-actions bot dismissed their stale review February 24, 2026 12:25

CHANGELOG updated or no update needed, thanks! 😄

@kami922
Copy link
Contributor Author

kami922 commented Feb 24, 2026

Hi @mr-tz @mike-hunhoff , I tried to run the workflow on my fork to produce a cold vs warm benchmark (run 1 = cache miss, run 2 = cache hit) before asking for review, but the workflow only triggers on push: branches: [master] and pull_request: branches: [master], so no runs fired on my fork's branch.

The local benchmark numbers in the description (8.65s warm vs 118.95s cold) demonstrate the mechanism works, but I understand you may want to see actual CI timing from GitHub runners. Could you advise the best way to verify this — should I add a temporary workflow_dispatch trigger to allow a manual run on the fork, or would you prefer to just approve the workflows here on the PR and compare run 1 vs run 2 timings directly?

pip install -r requirements.txt
pip install -e .[dev,scripts]
- name: Cache vivisect workspaces
uses: actions/cache@v4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use the pinned version like we do for other actions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mr-tz Done pinned version to hash,

@mr-tz
Copy link
Collaborator

mr-tz commented Feb 24, 2026

one minor comment, then I think we can merge and see how this behaves

@kami922 kami922 force-pushed the fix-556-vivisect-workspace-cache branch from aa58981 to ed34ffd Compare February 24, 2026 23:01
@kami922
Copy link
Contributor Author

kami922 commented Feb 24, 2026

@mr-tz Done and awaiting for your review

@mr-tz mr-tz merged commit 10dfd28 into mandiant:master Feb 25, 2026
34 checks passed
@mr-tz
Copy link
Collaborator

mr-tz commented Feb 25, 2026

Thanks, we'll see how this helps now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize running time of tests

2 participants